#!/bin/bash

### modify start...

# Create datakit user
# function create_datakit_user() {
#   sqlplus -s / as sysdba <<EOF
#       -- Create the datakit user. Replace the password placeholder with a secure password.
#       CREATE USER datakit IDENTIFIED BY 123456;

#       -- Grant access to the datakit user.
#       GRANT CONNECT TO datakit;
#       GRANT SELECT ON GV_\$PROCESS TO datakit;
#       GRANT SELECT ON gv_\$sysmetric TO datakit;
#       GRANT SELECT ON sys.dba_data_files TO datakit;
#       GRANT SELECT ON sys.dba_tablespaces TO datakit;
#       GRANT SELECT ON sys.dba_tablespace_usage_metrics TO datakit;

#       -- Initialize testing data.
#       CREATE TABLE students  ( student_id number(10) NOT NULL,  student_name varchar2(40) NOT NULL,  student_age varchar2(10)  );
#       INSERT INTO students  (student_id, student_name, student_age)  VALUES  (3, 'Happy', '11');
#       exit;
# EOF

# echo ""
# echo "#########################"
# echo "CREATED datakit USER!"
# echo "#########################"

# }

# create_datakit_user

# nohup /opt/run/run.sh > /tmp/start_oracle.log 2>&1 &
nohup /opt/oracle/oracle --interval $DATAKIT_INTERVAL --host 0.0.0.0 --port 1521 --username datakit --password 123456 --service-name $ORACLE_SID --datakit-http-host $DATAKIT_HOST --datakit-http-port $DATAKIT_PORT > /tmp/start_oracle.log 2>&1 &

echo ""
echo "#########################"
echo "LAUNCHED datakit COLLECTOR!"
echo "#########################"

### modify end...
